<?php

namespace Fendx\Funcs;

class FendxPage {

    public static function getPage(int $limit, int $offset): int {
        $page = ($offset / $limit) - 1;
        if ($page < 1) {
            return 1;
        }
        return $page;
    }

    public static function getOffset(int $page, int $limit): int {
        return ($page - 1) * $limit;
    }

    public static function getPages(int $total, int $limit): int {
        return (int) ceil($total / $limit);
    }
}
